<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- jsp文件头和头部 -->
    <%@ include file="../../base/top.jsp"%>
    <link rel="stylesheet" href="static/css/my_project_details/my_project_details1.css">
    <style>
        body{
            width: 100%;
            overflow: hidden;
            background: #ffffff;
        }
        .modal-dialog{
            z-index: 9999;
        }
    </style>
</head>
<body class="no-skin">
<div class="row">
    <div class="border" >
        <table border="0" class="tablegrad" align="left" style="width: 100%">
            <tr>
                <td align="center"><p style="text-align: center; line-height:50px; font-size: 25px; color: #6FAED9;">
                    ${projectBasicDetail.projectInfo.projectName}</p></td>
            </tr>
            <tr>
                <td width="300px" align="center">
                    <ul class="page_steps">
                        <c:forEach items="${projectBasicDetail.projectStageDetail.stageCompleteDetailList}" var="stageDetail">
                            <li data-step="1" <c:if test="${stageDetail.stageComplete}">class="page_active"</c:if> >
                            <span class="page_title"><c:if test="${empty stageDetail.stageGrade}">&nbsp;</c:if>${stageDetail.stageGrade}</span>
                            <span class="page_step"></span>
                            <span class="page_title">${stageDetail.stageName}</span>
                            </li>
                        </c:forEach>
                    </ul>
                </td>
                <td rowspan="3" width="300px">
                    <table  class="" align="center" border="0">
                        <tr>
                            <td class="edit" width="300px" align="right">
                                <div class="address">
                                    <c:if test="${not empty projectBasicDetail.projectInfo.projectDeploymentAddress}"><a href="${projectBasicDetail.projectInfo.projectDeploymentAddress}" target="_blank">查看部署</a></c:if>
                                    <c:if test="${empty projectBasicDetail.projectInfo.projectDeploymentAddress}">尚未部署</c:if>
                                </div>
                                <div class="form-group input-address hide">
                                    <label for="address-input" style="float: left">部署：</label>
                                    <input style="float: left;width:100px " type="text" class="form-control input-sm" id="address-input" value="${projectBasicDetail.projectInfo.projectDeploymentAddress}">
                                    <div style="width: 120px;float: right">
                                        <a style="float: left;margin-right: 5px;margin-left: 10px" id="${projectBasicDetail.projectInfo.projectId}" class="btn btn-success btn-sm" onclick="changeAddress(this.id)">确定</a>
                                        <a style="float: left" class="btn btn-danger btn-sm" onclick="hideInputAddress()">取消</a>
                                    </div>
                                </div>
                            </td>
                            <td class="center">
                                <a onclick="deployAddress()"><i class="ace-icon fa fa-pencil-square-o bigger-120" title="部署"></i></a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td >
                    <table border="0" style="margin: auto;height: 50px;">
                        <tr>
                            <td class="center" style="padding-right: 10px;">小组成员:
                                <c:forEach items="${projectBasicDetail.studentInfos}" var="student">
                                    ${student.stuName}
                                </c:forEach>
                            </td>
                            <td class="center" style="padding-right: 10px;">项目创建时间:${projectBasicDetail.projectInfo.projectCreateTime}</td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div><!-- /.border -->
</div><!-- /.row -->
<div class="row_content" style="margin-top: 30px;">
    <div  id="d0">
        <ul class="imm">
            <c:forEach items="${projectBasicDetail.assignmentFiles}" var="assignmentInfo">
                <li><a href="assignment/viewFlowAssignment?assignmentId=${assignmentInfo.assignmentId}&teaId=${assignmentInfo.teaId}" target="_parent"><img class="im3" src="static/images/office-icon/word.ico" ></a><p class="docunm">${assignmentInfo.assignmentName}</p></li>
            </c:forEach>
        </ul>
    </div>
    <ul class="lr1" style="list-style-type:none">
        <li class="pre1">
            <button class="btn btn-prev">
                <i class="ace-icon fa fa-arrow-left"></i>Prev</button>
        </li>
        <li class="next1">
            <button class="btn btn-success btn-next" data-last="Finish">
                Next
                <i class="ace-icon fa fa-arrow-right icon-on-right"></i>
            </button>
        </li>
    </ul>
</div>
<div class="gra_btn">
    <a class="btn btn-mini btn-primary" onclick="uploadFlowAssignment();">上传流程作业</a>
</div>

<%@ include file="../../base/foot.jsp" %>
<script >
    //显示部署输入框
    function deployAddress(){
        $(".address").removeClass("show");
        $(".input-address").addClass("show");
        $(".address").addClass("hide");
    }
    //取消部署
    function hideInputAddress() {
        $(".input-address").removeClass("show");
        $(".input-address").addClass("hide");
        $(".address").addClass("show");
    }
    //部署地址
    function changeAddress(id) {
        var address = $("#address-input").val();
        $.ajax({
            type:"POST",
            url:"<%=basePath%>project/editAddress",
            data:{
                projectId:id,
                projectAddress:address
            },
            dataType:'json',
            success:function (data) {
                if(data["success"]==true){
                    prompt_alert('success',data["msg"],0);
                    window.location.reload();
                }else{
                    operateError(data["msg"]);
                }
            }
        });
    }

    //图片播放
    $(function(){
        //图片自动轮播效果
        var a=0;
//		var automatic=setInterval(function(){
//			a++;
//			a=a%9;
//			$(".imm").animate({marginLeft:-160*a},"slow");
//		},3000);
        //点击左右按钮，图片进行切换效果
        $(".pre1").click(function(){
            a--;
            a=(a+9)%9;
            $(".imm").animate({marginLeft:-160*a},"slow");
        });
        $(".next1").click(function(){
            a++;
            a=a%9;
            $(".imm").animate({marginLeft:-160*a},"slow");
        });
    });
    //上传流程作业
    function uploadFlowAssignment() {
        $.ajax({
            type:"POST",
            url:"<%=basePath%>assignment/viewLatestAssignment",
            data:{
                projectId:"${projectBasicDetail.projectInfo.projectId}",
                <%--stageId:"${stageId}"--%>
            },
            dataType:'json',
            success:function (data) {
                if(data["code"]==1){//暂时不能上传
                    operateError(data["msg"]);
                }else if (data["code"]==0||data["code"]==2) {
                    bootbox.confirm(data["msg"], function(result) {
                        if (result){
                            var diag = new top.Dialog();
                            diag.Drag=true;
                            diag.Title ="上传";
                            if (data["code"]==0){ //更新的
                                // var obj = eval(data);
                                // //alert(obj.data.assignmentId);
                                // var assignmentInfo ={
                                //     assignmentId:obj.data.assignmentId,
                                //     assignmentOldAddress:obj.data.assignmentAddress
                                // }
                                diag.URL = '<%=basePath%>assignment/toUpload?type=0';
                            }else if(data["code"]==2){//下一版本
                                diag.URL = '<%=basePath%>assignment/toUpload?type=1';
                            }
                            diag.Width = 400;
                            diag.Height = 120;
                            diag.CancelEvent = function(){ //关闭事件
                                var success = diag.innerFrame.contentWindow.document.getElementById('success').value;
                                var msg = diag.innerFrame.contentWindow.document.getElementById('msg').value;
                                diag.close();
                                if("true" == success){
                                    prompt_alert('success',msg,0);
                                    window.location.reload();
                                }else if("false"==success){
                                    operateError(msg);
                                }
                            };
                            diag.show();
                        }
                    });
                }
            }
        });
    }
</script>

</body>
</html>
